#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
	int N;
	cin>>N;

	int n = 1;
	int **arr = new int*[N];
	while (n <= N) {
		int number;
		int *row = new int[n];
		for(int i = 0; i < n; i++) {
			cin>>number;
			row[i] = number;
		}
		arr[n - 1] = row;
		n++;		
	}
	int i, j;
	
	int **result = new int*[N];
	
	for (i = 0; i < N; i++) {
		int *interResult = new int[i + 1];
		if( i == 0) {
			interResult[0] = arr[i][0];
			result[i] = interResult;
		} else {
			int *preResult = result[i - 1];
			for (j = 0; j < i + 1; j++) {
				int addEnd1 = arr[i][j];
				int alternativeAddEnd = j > 0 ? preResult[j - 1] : 0;
				int alternativeAddEnd1 = j < i ? preResult[j] : 0;
				int addEnd2 = alternativeAddEnd > alternativeAddEnd1 ? alternativeAddEnd : alternativeAddEnd1;
				interResult[j] = addEnd1 + addEnd2;
			}
			result[i] = interResult;
		}		
	}

	int maxSum = result[N - 1][0];
	for (i = 1; i < N; i++) {
		if (result[N - 1][i]  > maxSum)
			maxSum = result[N - 1][i];
	}
	cout<<maxSum<<endl;
	delete[] arr;
	delete[] result;
	return 0;
}
